﻿Imports Microsoft.VisualBasic
Imports System.Data

<System.ComponentModel.DataObjectAttribute(True)> _
Public Class BLL_SearchAward

    Public Sub New()
        ' 
        ' TODO: 在此加入建構函式的程式碼 
        ' 
    End Sub

    'SELECT 
    <System.ComponentModel.DataObjectMethod(System.ComponentModel.DataObjectMethodType.[Select])> _
    Public Function BLL_Select(ByVal AwardName As String, ByVal Annual As Integer) As DataTable

        Dim sql As New MyStringBuilder
        Dim dat As New clsData

        sql.AppendFormat("SELECT A.* ")
        sql.AppendFormat("FROM Award A ")
        sql.AppendFormat("WHERE (A.AwardName like '%{0}%' or '{0}'=''  ) ", AwardName)
        sql.AppendFormat("AND (A.Annual = {0} or {0}=0  ) ", Annual)

        Return dat.GetData(sql)

    End Function

    'Delete 
    <System.ComponentModel.DataObjectMethod(System.ComponentModel.DataObjectMethodType.Delete)> _
    Public Function BLL_Delete(ByVal original_AwardID As Integer) As Integer

        Dim sql As New MyStringBuilder
        Dim dat As New clsData

        Using scope As New Transactions.TransactionScope

            sql.Length = 0

            sql.AppendFormat("DELETE Award WHERE AwardID={0};DELETE AwardRecord WHERE AwardID={0} ", original_AwardID)

            dat.AccData(sql)

            scope.Complete()
            '
            Return 1

        End Using

    End Function

End Class
